﻿using Gozib.Data.Contracts;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Gozib.Data.Model;

namespace Gozib.Data
{
  public class UoW : IUoW, IDisposable
  {
    private GozibDbContext dbContext { get; set; }

    public void Commit()
    {
      dbContext.SaveChanges();
    }

    public IRepository<BookingDetail> BokingDetails
    {
      get {return new EFRepository<BookingDetail>(dbContext);}
    }

    public IBookingDetailRepository Bookings
    {
      get{return new BookingDeailRepository(dbContext);}
    }

    public void Dispose()
    {
      dbContext.Dispose();
    }

    protected void CreateDbContext()
    {
      dbContext =new GozibDbContext();
      dbContext.Configuration.ProxyCreationEnabled = false;
      dbContext.Configuration.LazyLoadingEnabled = false;
      dbContext.Configuration.ValidateOnSaveEnabled = false;
    }
  }
}
